<template>
  <div>
    <p>我是哥哥组件的数据{{ count }}</p>
    <button @click="count++">增加</button>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  name: "Header",
  data() {
    return {
      count: 0,
    };
  },
  watch: {
    count: {
      handler() {
        PubSub.publish("count", this.count);
      },
    },
  },
};
</script>

<style>
</style>